package com.lzhsite.mapreduce.sort;


import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
/**
 * 自定义比较器
 * @author Administrator
 * 2018年5月31日上午8:40:58
 */
public class DefineCompparator extends WritableComparator{
 
	protected DefineCompparator() {
		super(CombinationKey.class,true);
	}
	@Override
	public int compare(WritableComparable a, WritableComparable b) {
		
		CombinationKey ck1=(CombinationKey) a;
		CombinationKey ck2=(CombinationKey) b;
		int cp1 = ck1.getFirstKey().compareTo(ck2.getFirstKey());
		if(cp1!=0) {
			//结束排序
			return cp1;
		}else {
			return  ck1.getSecondKey()-ck2.getSecondKey();
		}
	}
}